package pers.kui.reader.controller.management;

import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import pers.kui.reader.entity.Book;
import pers.kui.reader.entity.Evaluation;
import pers.kui.reader.mapper.EvaluationMapper;
import pers.kui.reader.service.EvaluationService;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/**
 * @author liu
 * @date 2021/8/17
 * @apiNote
 */
@Controller
@RequestMapping("/management/evaluation")
public class MEvaluationController {
    @Resource
    private EvaluationService evaluationService;

    /**
     * 短评管理分页
     *
     * @param page  页数
     * @param limit 显示行数
     * @return
     */
    @GetMapping("/list")
    @ResponseBody
    public Map list(Integer page, Integer limit) {

        if (page == null) {
            page = 1;
        }
        if (limit == null) {
            limit = 10;
        }
        IPage<Evaluation> pageObject = evaluationService.paging(null, null, page, limit);
        Map result = new HashMap();
        //下边四个键值对，layui作为返回值必须要求的
        result.put("code", "0");
        result.put("msg", "success");
        result.put("data", pageObject.getRecords());//当前页面数据
        result.put("count", pageObject.getTotal());//未分页时记录总数
        return result;
    }
}
